home *** CD-ROM | disk | FTP | other *** search
/ Mission 3 / Mission 3.zip / Mission 3.iso / texte / 7up_pd / forms.c < prev    next >
C/C++ Source or Header  |  1998-10-29  |  46KB  |  1,734 lines

  1. /* Dialog Bibliothek */
  2. /*****************************************************************************
  3. *
  4. *                                              7UP
  5. *                                         Modul: FORMS.C
  6. *                                     (c) by TheoSoft '90
  7. *
  8. *****************************************************************************/
  9. #include <portab.h>
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #include <ctype.h>
  14. #if GEMDOS
  15. #include <tos.h>
  16. #else
  17. #include <alloc.h>
  18. #endif
  19. #include <aes.h>
  20. #include <vdi.h>
  21.  
  22. #include "7up.h"
  23. #include "forms.h"
  24. #include "windows.h"
  25.  
  26. #include "language.h"
  27.  
  28. #define Objc_edit(a,b,c,d,e,f) objc_edit(a,b,c,f,e)
  29.  
  30. #define FLAGS11 0x0800
  31. #define FLAGS12 0x1000
  32. #define FLAGS13 0x2000
  33. #define FLAGS14 0x4000
  34. #define FLAGS15 0x8000
  35.  
  36. #define SCROLLFIELD FLAGS11
  37. #define UPARROW      FLAGS12
  38. #define DNARROW      FLAGS13
  39. #define SCROLLBOX    FLAGS14
  40.  
  41. #if GEMDOS
  42. #define FMD_FORWARD  1
  43. #define FMD_BACKWARD 2
  44. #define FMD_DEFLT     0
  45. #else
  46. #define ED_START          0 /* editable text field definitions */
  47. #define ED_INIT            1
  48. #define ED_CHAR            2
  49. #define ED_END             3
  50. #endif
  51.  
  52. #define AV_SENDKEY 0x4710
  53.  
  54. #define BACKDROP            0x2000  /* Fensterelement */
  55. #define WM_BACKDROPPED    31        /* Message vom Eventhandler */
  56. #define WF_BACKDROP        100      /* Fenster setzen */
  57.  
  58. #define CR     0x1C0D
  59. #define ENTER 0x720D
  60. #define TAB    0x0F09
  61. #define UPARR 0x4800
  62. #define DNARR 0x5000
  63. #define F1     0x3B00
  64. #define F12    0x4600
  65. #define UNDO  0x6100
  66. #define HELP  0x6200
  67.  
  68. static FDB ps[MAX_DEPTH], /* Source = Screen */
  69.               pd[MAX_DEPTH], /* Dest.  = Buffer */
  70.               pb[MAX_DEPTH]; /* Box     = Dialogbox */
  71.  
  72. int windials=FALSE;
  73.  
  74. static int FDBcount=-1;
  75. int dial_handle=-1;
  76.  
  77. #define M_ENDLESS 0x0001
  78. #define M_VALID    0x0002
  79. #define M_REC      0x0004
  80. #define M_PLAY     0x0008
  81.  
  82. extern OBJECT *divmenu,*winmenu;
  83. extern int aeshandle,vdihandle,userhandle,xdesk,ydesk,wdesk,hdesk,windials,boxw,boxh;
  84.  
  85. int draw_rbutton();
  86. int draw_checkbox();
  87. int draw_alt();
  88.  
  89. #if GEMDOS
  90. /* ------------------------------------------------------------------------- */
  91. /* ----- VSCR von BIGSCREEN 2 ---------------------------------------------- */
  92. /* ------------------------------------------------------------------------- */
  93.  
  94. typedef struct
  95. {
  96.     LONG cookie;    /* muß `VSCR' sein */
  97.     LONG product;  /* Analog zur XBRA-Kennung */
  98.     WORD version;  /* Version des VSCR-Protokolls, zunächst 0x100 */
  99.     WORD x,y,w,h;  /* Sichtbarer Ausschnitt des Bildschirms */
  100. } INFOVSCR;
  101.  
  102.  
  103. /* ------------------------------------------------------------------------- */
  104. /* ----- di_fly.c ----- Flying Dials using Let em Fly! --------------------- */
  105. /* ------------------------------------------------------------------------- */
  106.  
  107. #include "di_fly.h"
  108.  
  109. /* ------------------------------------------------------------------------- */
  110.  
  111. static LTMFLY    *letemfly = NULL;
  112.  
  113. /* ----- Cookie Jar -------------------------------------------------------- */
  114.  
  115. #endif
  116.  
  117. /*------------------------------------------------------------------------*/
  118. /*                                                                                                */
  119. /*------------------------------------------------------------------------*/
  120. void fwind_redraw(OBJECT *tree, int wh, int pxyarray[])
  121. {
  122.     int full[4],area[4],array[4],ret;
  123.  
  124.     wind_update(BEG_UPDATE);
  125.     _wind_get( 0, WF_WORKXYWH,  &full[0], &full[1], &full[2], &full[3]);
  126.     _wind_get(wh, WF_FIRSTXYWH, &area[0], &area[1], &area[2], &area[3]);
  127.     while( area[2] && area[3] )
  128.     {
  129.         if(rc_intersect(full,area))
  130.         {
  131.             if(rc_intersect(pxyarray,area))
  132.             {
  133.                 objc_draw(tree,ROOT,MAX_DEPTH,area[0],area[1],area[2],area[3]);
  134.             }
  135.         }
  136.         _wind_get(wh, WF_NEXTXYWH,&area[0],&area[1],&area[2],&area[3]);
  137.     }
  138.     wind_update(END_UPDATE);
  139. }
  140.  
  141. void fwind_move(OBJECT *tree, int wh, int buf[])
  142. {
  143.     int xwork,ywork,wwork,hwork;
  144.  
  145.     wind_set(wh,WF_CURRXYWH,buf[0],buf[1],buf[2],buf[3]);
  146.     _wind_get(wh,WF_WORKXYWH,&xwork,&ywork,&wwork,&hwork);
  147.     tree->ob_x=xwork;
  148.     tree->ob_y=ywork;
  149. }
  150.  
  151. static int is_obj_char(char *str)
  152. {
  153.     char *cp;
  154.     if((cp=strchr(str,'_'))!=0L)
  155.         return(__tolower(*(cp+1L)));
  156.     return(0);
  157. }
  158.  
  159. static int find_altbutton(OBJECT *tree, int fm_key)
  160. {
  161.     register int i;
  162.     for(i=ROOT+2; !(tree[i].ob_flags & LASTOB); i++)
  163.     {
  164.         if(tree[i].ob_type == G_USERDEF &&
  165.             !(tree[i].ob_flags&HIDETREE) &&
  166.             !(tree[i].ob_state&DISABLED) &&
  167.             !(tree[i].ob_flags&FLAGS15)) /* wg. Zeichensatztabelle */
  168.         {
  169.             if(fm_key ==
  170. is_obj_char((char *)((TEDINFO *)tree[i].ob_spec.userblk->ub_parm)->te_ptext))
  171.                 return(i);
  172.         }
  173.     }
  174.     if(tree[i].ob_type == G_USERDEF &&
  175.         !(tree[i].ob_flags&HIDETREE) &&
  176.         !(tree[i].ob_state&DISABLED) &&
  177.         !(tree[i].ob_flags&FLAGS15)) /* wg. Zeichensatztabelle */
  178.     {
  179.             if(fm_key ==
  180. is_obj_char((char *)((TEDINFO *)tree[i].ob_spec.userblk->ub_parm)->te_ptext))
  181.                 return(i);
  182.     }
  183.     return(-1);
  184. }
  185.  
  186. char *stristr(char *, char *);
  187.  
  188. static int find_button(OBJECT *tree, char *string)
  189. {
  190.     register int i;
  191.     for(i=ROOT+2; !(tree[i].ob_flags & LASTOB); i++)
  192.     {
  193.         if(!(tree[i].ob_flags&HIDETREE) && !(tree[i].ob_state&DISABLED))
  194.         {
  195.             if((tree[i].ob_type == G_USERDEF) && !(tree[i].ob_flags & FLAGS15))
  196.             {
  197.                 if(stristr((char *)((TEDINFO *)tree[i].ob_spec.userblk->ub_parm)->te_ptext,string))
  198.                     return(i);
  199.             }
  200.             else
  201.             {
  202.                 if(tree[i].ob_type == G_BOXTEXT)
  203.                     if(stristr(tree[i].ob_spec.tedinfo->te_ptext,string))
  204.                         return(i);
  205.             }
  206.         }
  207.     }
  208.     if(!(tree[i].ob_flags&HIDETREE) && !(tree[i].ob_state&DISABLED))
  209.     {
  210.         if((tree[i].ob_type == G_USERDEF) && !(tree[i].ob_flags&FLAGS15))
  211.         {
  212.             if(stristr((char *)((TEDINFO *)tree[i].ob_spec.userblk->ub_parm)->te_ptext,string))
  213.                 return(i);
  214.         }
  215.         else
  216.         {
  217.               if(tree[i].ob_type == G_BOXTEXT)
  218.                 if(stristr(tree[i].ob_spec.tedinfo->te_ptext,string))
  219.                     return(i);
  220.         }
  221.     }
  222.     return(-1);
  223. }
  224.  
  225. static int find_fflag(OBJECT *tree, int start, int flag) /* first_flag */
  226. {
  227.     register int i;
  228.     for(i=start; !(tree[i].ob_flags & LASTOB); i++)
  229.     {
  230.         if(tree[i].ob_flags & flag)
  231.             return(i);
  232.     }
  233.     if(tree[i].ob_flags & flag)
  234.         return(i);
  235.     return(-1);
  236. }
  237.  
  238. static int count_flag(OBJECT *tree, int start, int flag) /* first_flag */
  239. {
  240.     register int i,count=0;
  241.     for(i=start; !(tree[i].ob_flags & LASTOB); i++)
  242.     {
  243.         if(tree[i].ob_flags & flag)
  244.             count++;
  245.     }
  246.     if(tree[i].ob_flags & flag)
  247.         count++;
  248.     return(count);
  249. }
  250.  
  251. static int find_lflag(OBJECT *tree, int start, int flag) /* last_flag */
  252. {
  253.     register int i,k;
  254.     for(i=start; !(tree[i].ob_flags & LASTOB); i++)
  255.     {
  256.         if(tree[i].ob_flags & flag)
  257.         {
  258.             for(k=i; !(tree[k].ob_flags & LASTOB); k++)
  259.             {
  260.                 if(!(tree[k].ob_flags & flag))
  261.                     return(k-1);
  262.             }
  263.             return(i);
  264.         }
  265.     }
  266.     return(-1);
  267. }
  268.  
  269. static int find_bflag(OBJECT *tree, int start, int flag) /* rückwärts */
  270. {
  271.     register int i;
  272.     for(i=start; i>=ROOT+2; i--)
  273.     {
  274.         if(tree[i].ob_flags & flag)
  275.             return(i);
  276.     }
  277.     return(-1);
  278. }
  279.  
  280. static int form_click(OBJECT *tree, int next_obj, int e_br, int *next_obj2)
  281. {
  282.     int fm_cont=TRUE;
  283.     switch(next_obj)
  284.     {
  285.         case ROOT:
  286.             break;
  287.         case (-1):
  288. #if GEMDOS
  289.             Bconout(2,7);
  290. #else
  291.             v_sound(aeshandle, 440, 2);
  292. #endif
  293.             *next_obj2=0;
  294.             break;
  295.         default:
  296.             fm_cont=form_button(tree,next_obj,e_br,next_obj2);
  297.             break;
  298.     }
  299.     return(fm_cont);
  300. }
  301.  
  302. static WORD find_obj(OBJECT *tree, WORD fm_start_obj, WORD fm_which)
  303. {
  304.     WORD fm_obj,fm_flag,fm_theflag,fm_inc;
  305.     fm_obj=0;
  306.     fm_flag=EDITABLE;
  307.     fm_inc=1;
  308.     switch(fm_which)
  309.     {
  310.         case FMD_BACKWARD: fm_inc=-1;
  311.         case FMD_FORWARD:  fm_obj=fm_start_obj+fm_inc;break;
  312.         case FMD_DEFLT:     fm_flag=2;
  313.             break;
  314.     }
  315.     while(fm_obj>=0)
  316.     {
  317.         fm_theflag=tree[fm_obj].ob_flags;
  318.         if(fm_theflag&fm_flag)
  319.             return(fm_obj);
  320.         if(fm_theflag&LASTOB)
  321.             fm_obj=-1;
  322.         else
  323.             fm_obj+=fm_inc;
  324.     }
  325.     return(fm_start_obj);
  326. }
  327.  
  328. /*------------------------------------------------------------------------*/
  329. /*                                                                                                */
  330. /*------------------------------------------------------------------------*/
  331. static WORD fm_inifld(OBJECT *tree, WORD fm_start_fld)
  332. {
  333.     if(fm_start_fld==0)
  334.         fm_start_fld=find_obj(tree,0,FMD_FORWARD);
  335.     return(fm_start_fld);
  336. }
  337.  
  338. static int _form_exdo(OBJECT *tree, WORD fm_start_fld)
  339. {
  340.     WORD obj,fm_edit_obj,fm_next_obj,fm_which,fm_cont,fm_idx,fm_kr2;
  341.     WORD oldstate,i,txtcrsr=FALSE,x,y,diff,selected=FALSE;
  342.     char ch;
  343.  
  344.     static int msgbuf[8];
  345.     static MEVENT mevent=
  346.     {
  347.         MU_KEYBD|MU_BUTTON|MU_MESAG|MU_M1|MU_TIMER,
  348.         2,1,1,
  349.         1,0,0,1,1,
  350.         0,0,0,0,0,
  351.         msgbuf,
  352.         0L,                    /* bei Makro: 16L, */
  353.         0,0,0,0,0,0,
  354.     /* nur der Vollständigkeit halber die Variablen von XGEM */
  355.         0,0,0,0,0,
  356.         0,
  357.         0L,
  358.         0L,0L
  359.     };
  360.  
  361. #if GEMDOS
  362.     KEYTAB *pkeytbl;
  363.     char *kbdu, *kbds, *kbdc, chr;
  364.  
  365.     pkeytbl=Keytbl(-1L,-1L,-1L);
  366.     kbdu=pkeytbl->unshift;
  367.     kbds=pkeytbl->shift;
  368.     kbdc=pkeytbl->capslock;
  369. #else
  370.     extern unsigned char b_keycod[];
  371.     int scan;
  372. #endif
  373.  
  374.     mevent.e_flags=MU_KEYBD|MU_BUTTON|MU_M1|MU_TIMER;
  375.     if(windials && !(tree->ob_flags & FLAGS15))
  376.         mevent.e_flags|=MU_MESAG;
  377.     
  378.     fm_next_obj=fm_inifld(tree,fm_start_fld);
  379.     fm_edit_obj=0;
  380.     fm_cont=TRUE;
  381.  
  382.     while(fm_cont)
  383.     {
  384.         if((fm_next_obj!=0)&&(fm_edit_obj!=fm_next_obj))
  385.         {
  386.             fm_edit_obj=fm_next_obj;
  387.             fm_next_obj=0;
  388.             Objc_edit(tree,fm_edit_obj,0,fm_idx,ED_INIT,&fm_idx);
  389.         }
  390.         mevent.e_m1.g_x=mevent.e_mx;
  391.         mevent.e_m1.g_y=mevent.e_my;
  392.  
  393.         fm_which=evnt_event(&mevent);
  394. /*
  395.         wind_update(BEG_UPDATE);
  396. */
  397.         if(fm_which & MU_MESAG)
  398.         {
  399.             if((msgbuf[0] != MN_SELECTED) && (msgbuf[0] < 50)) /* AP_TERM */
  400.             {
  401.                 if(msgbuf[3]==dial_handle) /* Dialogfenster */
  402.                 {
  403.                     switch(msgbuf[0])
  404.                     {
  405.                         case WM_BACKDROPPED: /* nein, niemals */
  406.                             break;
  407.                         case WM_REDRAW:
  408.                             Objc_edit(tree,fm_edit_obj,0,fm_idx,ED_END,&fm_idx);
  409.                             fwind_redraw(tree,msgbuf[3],&msgbuf[4]);
  410.                             Objc_edit(tree,fm_edit_obj,0,fm_idx,ED_INIT,&fm_idx);
  411.                             break;
  412.                         case WM_MOVED:
  413.                             Objc_edit(tree,fm_edit_obj,0,fm_idx,ED_END,&fm_idx);
  414.                             fwind_move(tree,msgbuf[3],&msgbuf[4]);
  415.                             Objc_edit(tree,fm_edit_obj,0,fm_idx,ED_INIT,&fm_idx);
  416.                             break;
  417.                         case WM_TOPPED:
  418.                             wind_set(msgbuf[3],WF_TOP,0,0,0,0);
  419.                             break;
  420.                     }
  421.                 }
  422.                 else /* aber kein Schließen oder Toppen */
  423.                     if(msgbuf[0]!=WM_CLOSED && msgbuf[0]!=WM_TOPPED)
  424.                     {
  425.                         Wwindmsg(Wp(msgbuf[3]),msgbuf);
  426.                     }
  427.             }
  428.         }
  429.         if(fm_which & MU_KEYBD)
  430.         {
  431.             if(find_fflag(tree,ROOT+2,EDITABLE)>0)
  432.                 altnum(&mevent.e_ks,&mevent.e_kr);
  433.             if(mevent.e_ks == K_ALT)
  434.             {
  435. #if GEMDOS
  436.                 fm_kr2= *(kbdu+(mevent.e_kr>>8 & 0xff));
  437. #else
  438.                 scan=(mevent.e_kr>>8 & 0xff);
  439.                 for(i='a'; i<='z'; i++)
  440.                     if(scan==b_keycod[i-'a'])
  441.                     {
  442.                         fm_kr2=(char)(i);
  443.                         break;
  444.                     }
  445.                 /* ALT-Y und ALT-Z tauschen                 */
  446.                 if(mevent.e_ks & K_ALT && scan==44 && fm_kr2==121)
  447.                     fm_kr2=122;
  448.                 if(mevent.e_ks & K_ALT && scan==21 && fm_kr2==122)
  449.                     fm_kr2=121;
  450.                 if(scan>=120 && scan<=129)
  451.                     fm_kr2=scan-120+1+'0';
  452. #endif
  453.                 fm_next_obj=find_altbutton(tree,__tolower(fm_kr2));
  454.                 switch(fm_next_obj)
  455.                 {
  456.                     case ROOT:
  457.                         break;
  458.                     case (-1):
  459.                         fm_next_obj=0;
  460.                         fm_cont=form_keybd(tree, fm_edit_obj, fm_next_obj, mevent.e_kr, &fm_next_obj, &mevent.e_kr);
  461.                         if(mevent.e_kr)
  462.                             Objc_edit(tree,fm_edit_obj,mevent.e_kr,fm_idx,ED_CHAR,&fm_idx);
  463.                         break;
  464.                     default:
  465.                         fm_cont=form_button(tree,fm_next_obj,mevent.e_br,&fm_next_obj);
  466.                         break;
  467.                 }
  468.             }
  469.             else
  470.             {
  471.                 switch(mevent.e_kr)
  472.                 {
  473.                     case 0x4700: /* home */
  474.                         if(count_flag(tree,ROOT+2,EDITABLE)>1)
  475.                             goto WEITER3; /* kein Scrollen möglich, weil EDITABLE */
  476.                         if((fm_next_obj=find_fflag(tree,ROOT+2,FLAGS11))>-1)
  477.                         {
  478.                             fm_cont=form_click(tree,fm_next_obj,1,&fm_next_obj);
  479.                             fm_next_obj=find_fflag(tree,ROOT+2,FLAGS12);
  480.                             fm_cont=form_click(tree,fm_next_obj,2,&fm_next_obj);
  481.                         }
  482.                         break;
  483.                     case 0x4737: /* clr */
  484.                         if(count_flag(tree,ROOT+2,EDITABLE)>1)
  485.                             goto WEITER3; /* kein Scrollen möglich, weil EDITABLE */
  486.                         if((fm_next_obj=find_lflag(tree,ROOT+2,FLAGS11))>-1)
  487.                         {
  488.                             fm_cont=form_click(tree,fm_next_obj,1,&fm_next_obj);
  489.                             fm_next_obj=find_fflag(tree,ROOT+2,FLAGS13);
  490.                             fm_cont=form_click(tree,fm_next_obj,2,&fm_next_obj);
  491.                         }
  492.                         break;                    
  493.                     case 0x4838: /* shift up */
  494.                         if(count_flag(tree,ROOT+2,EDITABLE)>1)
  495.                             goto WEITER3; /* kein Scrollen möglich, weil EDITABLE */
  496.                         if((fm_next_obj=find_fflag(tree,ROOT+2,FLAGS11))>-1)
  497.                         {
  498.                             if(!(tree[fm_next_obj].ob_state & SELECTED))
  499.                                 fm_cont=form_click(tree,fm_next_obj,1,&fm_next_obj);
  500.                             else
  501.                             {
  502.                                 fm_next_obj=find_fflag(tree,ROOT+2,FLAGS12);
  503.                                 fm_cont=form_click(tree,fm_next_obj,1,&fm_next_obj);
  504.                             }
  505.                         }
  506.                         break;
  507.                     case 0x4800: /* up */
  508.                         if(count_flag(tree,ROOT+2,EDITABLE)>1)
  509.                             goto WEITER3;
  510.                         if((fm_next_obj=find_fflag(tree,ROOT+2,FLAGS11))>-1)
  511.                         {
  512.                             for(i=fm_next_obj; !(tree[i].ob_flags & LASTOB); i++)
  513.                                 if((tree[i].ob_flags & FLAGS11) && (tree[i].ob_state & SELECTED))
  514.                                 {
  515.                                     selected=TRUE;
  516.                                     if(tree[i-1].ob_flags & FLAGS11)
  517.                                     {
  518.                                         fm_next_obj=--i;
  519.                                         break;
  520.                                     }
  521.                                 }
  522.                             if(!selected)
  523.                                 fm_next_obj=find_lflag(tree,ROOT+2,FLAGS11);
  524.                             else
  525.                                 if(i!=fm_next_obj)
  526.                                     fm_next_obj=find_fflag(tree,ROOT+2,FLAGS12);
  527.                         }
  528.                         fm_cont=form_click(tree,fm_next_obj,1,&fm_next_obj);
  529.                         break;
  530.                     case 0x5032: /* shift dn */
  531.                         if(count_flag(tree,ROOT+2,EDITABLE)>1)
  532.                             goto WEITER3; /* kein Scrollen möglich, weil EDITABLE */
  533.                         if((fm_next_obj=find_lflag(tree,ROOT+2,FLAGS11))>-1)
  534.                         {
  535.                             if(!(tree[fm_next_obj].ob_state & SELECTED))
  536.                                 fm_cont=form_click(tree,fm_next_obj,1,&fm_next_obj);
  537.                             else
  538.                             {
  539.                                 fm_next_obj=find_fflag(tree,ROOT+2,FLAGS13);
  540.                                 fm_cont=form_click(tree,fm_next_obj,1,&fm_next_obj);
  541.                             }
  542.                         }
  543.                         break;
  544.                     case 0x5000: /* dn */
  545.                         if(count_flag(tree,ROOT+2,EDITABLE)>1)
  546.                             goto WEITER3; /* kein Scrollen möglich, weil EDITABLE */
  547.                         if((fm_next_obj=find_fflag(tree,ROOT+2,FLAGS11))>-1) /* gibt es eine Scrolliste? */
  548.                         {  /* erstes selektiertes Objekt suchen */
  549.                             for(i=fm_next_obj; !(tree[i].ob_flags & LASTOB); i++)
  550.                                 if((tree[i].ob_flags & FLAGS11) && (tree[i].ob_state & SELECTED))
  551.                                 {
  552.                                     selected=TRUE; /* hier ist es! */
  553.                                     if(tree[i+1].ob_flags & FLAGS11)
  554.                                     {  /* ist das nächste Objekt auch scrollbar? */
  555.                                         fm_next_obj=++i; /* nur Cursor weitersetzen */
  556.                                         break;
  557.                                     }
  558.                                 }
  559.                             if(!selected) /* Es wurde kein selektiertes Objekt gefunden */
  560.                                 fm_next_obj=find_fflag(tree,ROOT+2,FLAGS11); /* erstes Objekt selektieren */
  561.                             else
  562.                                 if(i!=fm_next_obj) /* es gibt ein sel. Objekt, es ist aber das letzte */
  563.                                     fm_next_obj=find_fflag(tree,ROOT+2,FLAGS13); /* also Pfeil klicken */
  564.                         }
  565.                         fm_cont=form_click(tree,fm_next_obj,1,&fm_next_obj);
  566.                         break;
  567.                     case 0x4B00: /* lf */
  568.                     case 0x4B34: /* lf */
  569.                     case 0x4D00: /* rt */
  570.                     case 0x4D36: /* rt */
  571.                         if(count_flag(tree,ROOT+2,EDITABLE)>0)
  572.                             goto WEITER3;
  573.                         fm_next_obj=-1;
  574.                         fm_cont=form_click(tree,fm_next_obj,1,&fm_next_obj);
  575.                         break;
  576. #if GEMDOS
  577.                     case HELP:
  578. #else
  579.                     case F1:
  580. #endif
  581.                         fm_next_obj=find_button(tree,KHILFE);
  582.                         fm_cont=form_click(tree,fm_next_obj,mevent.e_br,&fm_next_obj);
  583.                         break;
  584.                     case UNDO:
  585.                         if((fm_next_obj=find_button(tree,KABBRUCH))==-1)
  586.                              fm_next_obj=find_button(tree,KNEIN);
  587.                         fm_cont=form_click(tree,fm_next_obj,mevent.e_br,&fm_next_obj);
  588.                         break;
  589.                     default:
  590. WEITER3:
  591.                         if(
  592. #if GEMDOS
  593.                              !letemfly &&
  594. #endif
  595.                              mevent.e_kr==TAB && (mevent.e_ks & (K_RSHIFT|K_LSHIFT)) )
  596.                         {
  597.                             mevent.e_kr =UPARR;
  598.                         }
  599.                         fm_cont=form_keybd(tree, fm_edit_obj, fm_next_obj, mevent.e_kr, &fm_next_obj, &mevent.e_kr);
  600.                         if(mevent.e_kr)
  601.                         {
  602.                             Objc_edit(tree,fm_edit_obj,mevent.e_kr,fm_idx,ED_CHAR,&fm_idx);
  603.                         }
  604. /* überflüssig mit neuer Lib
  605.                         /* gegen Fehler GEMBIND, wg. KAOS 1.41 */
  606.                         if(!fm_cont && !fm_next_obj)
  607.                         {
  608.                             fm_next_obj=find_fflag(tree,ROOT+2,DEFAULT);
  609.                             if(fm_next_obj==-1)
  610.                                 fm_cont=TRUE;
  611.                         }
  612. */
  613.                         break;
  614.                 }
  615.             }
  616. /* muß raus wg. Makrorecorder
  617.             while(evnt_event(&mevent) == MU_KEYBD) /* Puffer löschen */
  618.                 ;
  619. */
  620.         }
  621.         if(fm_which & MU_BUTTON)
  622.         {
  623.             fm_next_obj=objc_find(tree,ROOT,MAX_DEPTH,mevent.e_mx,mevent.e_my);
  624.             switch(fm_next_obj)
  625.             {
  626.                 case ROOT:
  627.                     break;
  628.                 case (-1):
  629. #if GEMDOS
  630.                     Bconout(2,7);
  631. #else
  632.                     v_sound(aeshandle, 440, 2);
  633. #endif
  634.                     fm_next_obj=0;
  635.                     break;
  636.                 default:
  637.                     fm_cont=form_button(tree,fm_next_obj,mevent.e_br,&fm_next_obj);
  638.                     if(!(fm_next_obj&FLAGS15) && (tree[fm_next_obj].ob_flags & EDITABLE))
  639.                     {
  640.                         diff=(tree[fm_next_obj].ob_spec.tedinfo->te_txtlen -
  641.                                 tree[fm_next_obj].ob_spec.tedinfo->te_tmplen);
  642.                         objc_offset(tree,fm_next_obj,&x,&y);
  643.                         mevent.e_mx+=(diff*8);
  644.                         y=(mevent.e_mx-x)/8;
  645.                         if((mevent.e_mx-x)%8 >= 4)
  646.                             y++;
  647.                         if(y<0)
  648.                             y=0;
  649.                         if(y>strlen(tree[fm_next_obj].ob_spec.tedinfo->te_ptext))
  650.                             y=strlen(tree[fm_next_obj].ob_spec.tedinfo->te_ptext);
  651.  
  652.                         Objc_edit(tree,fm_edit_obj,0,fm_idx,ED_END,&fm_idx);
  653.  
  654.                         ch=tree[fm_next_obj].ob_spec.tedinfo->te_ptext[y];
  655.                         tree[fm_next_obj].ob_spec.tedinfo->te_ptext[y]=0;
  656.                         Objc_edit(tree,fm_next_obj,0,fm_idx,ED_INIT,&fm_idx);
  657.                         tree[fm_next_obj].ob_spec.tedinfo->te_ptext[y]=ch;
  658.                         fm_edit_obj = fm_next_obj;
  659.                     }
  660.                     break;
  661.             }
  662. WEITER1: ;
  663.         }
  664.         if(fm_which & MU_M1) /* evtl. Textcursor einstellen */
  665.         {
  666.             if(dial_handle>0)
  667.             {
  668.                 if(wind_find(mevent.e_mx,mevent.e_my)!=dial_handle)
  669.                 {
  670.                     if(txtcrsr)
  671.                     {
  672.                         graf_mouse(ARROW,NULL);
  673.                         txtcrsr=FALSE;
  674.                     }
  675.                     goto WEITER2;
  676.                 }
  677.             }    
  678.             obj=objc_find(tree,ROOT,MAX_DEPTH,mevent.e_mx,mevent.e_my);
  679.             switch(obj)
  680.             {
  681.                 case ROOT:
  682.                 case (-1):
  683.                     if(txtcrsr)
  684.                     {
  685.                         graf_mouse(ARROW,NULL);
  686.                         txtcrsr=FALSE;
  687.                     }
  688.                     break;
  689.                 default:
  690.                     if(!txtcrsr &&  (tree[obj].ob_flags & EDITABLE)  /* editierbar */
  691.                                     && !(tree[obj].ob_state & DISABLED)  /* ! */
  692.                                     && !(tree[obj].ob_flags & HIDETREE)) /* ! */
  693.                     {
  694.                         graf_mouse(TEXT_CRSR,NULL);
  695.                         txtcrsr=TRUE;
  696.                     }
  697.                     if( txtcrsr && !(tree[obj].ob_flags & EDITABLE))
  698.                     {
  699.                         graf_mouse(ARROW,NULL);
  700.                         txtcrsr=FALSE;
  701.                     }
  702.                     break;
  703.             }
  704. WEITER2: ;
  705.         }
  706.         if((!fm_cont) || ((fm_next_obj != 0) && (fm_next_obj != fm_edit_obj)))
  707.         {
  708.             Objc_edit(tree,fm_edit_obj,mevent.e_kr,fm_idx,ED_END,&fm_idx);
  709.         }
  710. /*
  711.         wind_update(END_UPDATE);
  712. */
  713.     }
  714.     graf_mouse(ARROW,NULL);
  715.     return(fm_next_obj);
  716. }
  717.  
  718. void form_open(OBJECT *tree,int modus)
  719. {
  720. #if MiNT
  721.     wind_update(BEG_UPDATE);
  722.     wind_update(BEG_MCTRL);
  723. #endif
  724.     form_dial(FMD_START,0,0,0,0,tree->ob_x-3,tree->ob_y-3,
  725.                                          tree->ob_width+6,tree->ob_height+6);
  726.     if(modus)
  727.         form_dial(FMD_GROW,0,0,0,0,tree->ob_x-3,tree->ob_y-3,
  728.                                          tree->ob_width+6,tree->ob_height+6);
  729.     objc_draw(tree,ROOT,MAX_DEPTH,tree->ob_x-3,tree->ob_y-3,
  730.                                             tree->ob_width+6,tree->ob_height+6);
  731. }
  732.  
  733. int form_close(OBJECT *tree, int exit_obj,int modus)
  734. {
  735.     if(modus)
  736.         form_dial(FMD_SHRINK,0,0,0,0,tree->ob_x-3,tree->ob_y-3,
  737.                                          tree->ob_width+6,tree->ob_height+6);
  738.     form_dial(FMD_FINISH,0,0,0,0,tree->ob_x-3,tree->ob_y-3,
  739.                                          tree->ob_width+6,tree->ob_height+6);
  740.     if(exit_obj > -1 /*&& exit_obj < 256*/)
  741.         tree[exit_obj].ob_state &= ~SELECTED;
  742. #if MiNT
  743.     wind_update(END_MCTRL);
  744.     wind_update(END_UPDATE);
  745. #endif
  746.     return(exit_obj);
  747. }
  748.  
  749. static int _form_exopen(OBJECT *tree, int modus)
  750. {
  751.     long boxsize;
  752.     int pxyarray[8];
  753.  
  754.     extern int work_out[];
  755.  
  756.     if(FDBcount==MAX_DEPTH)
  757.         return(FALSE);
  758.  
  759.     vq_extnd(vdihandle,1,work_out);
  760.  
  761.     ps[FDBcount].fd_addr = pd[FDBcount].fd_addr = pb[FDBcount].fd_addr = NULL;
  762.     pd[FDBcount].fd_w = pb[FDBcount].fd_w = tree->ob_width+6;
  763.     pd[FDBcount].fd_h = pb[FDBcount].fd_h = tree->ob_height+6;
  764.     pd[FDBcount].fd_wdwidth = pb[FDBcount].fd_wdwidth =
  765.         pd[FDBcount].fd_w/16+ (pd[FDBcount].fd_w % 16 != 0);
  766.     pd[FDBcount].fd_stand = pb[FDBcount].fd_stand = 0;
  767.     pd[FDBcount].fd_nplanes = pb[FDBcount].fd_nplanes = work_out[4];
  768.     pd[FDBcount].fd_r1 = pd[FDBcount].fd_r2 = pd[FDBcount].fd_r3 = 0;
  769.     pb[FDBcount].fd_r1 = pb[FDBcount].fd_r2 = pb[FDBcount].fd_r3 = 0;
  770.  
  771.     boxsize=(long)pd[FDBcount].fd_wdwidth*2L*(long)pd[FDBcount].fd_h*(long)pd[FDBcount].fd_nplanes;
  772. #if GEMDOS
  773.     if((pd[FDBcount].fd_addr=Malloc(boxsize))==NULL) /* Speicher für Bildschirm besorgen */
  774.         return(FALSE);
  775.     if((pb[FDBcount].fd_addr=Malloc(boxsize))==NULL) /* Speicher für Bildschirm besorgen */
  776.     {
  777.         Mfree(pd[FDBcount].fd_addr);
  778.         pd[FDBcount].fd_addr=NULL;
  779.         return(FALSE);
  780.     }
  781. #else
  782.     if((pd[FDBcount].fd_addr=farmalloc(boxsize))==NULL) /* Speicher für Bildschirm besorgen */
  783.         return(FALSE);
  784.     if((pb[FDBcount].fd_addr=farmalloc(boxsize))==NULL) /* Speicher für Bildschirm besorgen */
  785.     {
  786.         farfree(pd[FDBcount].fd_addr);
  787.         pd[FDBcount].fd_addr=NULL;
  788.         return(FALSE);
  789.     }
  790.  
  791. #endif
  792.     if(modus)
  793.         form_dial(FMD_GROW,0,0,0,0,tree->ob_x-3,tree->ob_y-3,
  794.                                          tree->ob_width+6,tree->ob_height+6);
  795.  
  796.     graf_mouse(M_OFF,0L);
  797.     pxyarray[0]=tree->ob_x-3;
  798.     pxyarray[1]=tree->ob_y-3;
  799.     pxyarray[2]=tree->ob_x+tree->ob_width-1+3;
  800.     pxyarray[3]=tree->ob_y+tree->ob_height-1+3;
  801.     pxyarray[4]=0;
  802.     pxyarray[5]=0;
  803.     pxyarray[6]=tree->ob_width-1+6;
  804.     pxyarray[7]=tree->ob_height-1+6;
  805.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&ps[FDBcount],&pd[FDBcount]);
  806.     objc_draw(tree,ROOT,MAX_DEPTH,tree->ob_x-3,tree->ob_y-3,
  807.                                             tree->ob_width+6,tree->ob_height+6);
  808.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&ps[FDBcount],&pb[FDBcount]);
  809.     graf_mouse(M_ON,0L);
  810.     return(TRUE);
  811. }
  812.  
  813. static int _form_exclose(OBJECT *tree, int exit_obj, int modus)
  814. {
  815.     int pxyarray[8];
  816.  
  817.     if(modus)
  818.         form_dial(FMD_SHRINK,0,0,0,0,tree->ob_x-3,tree->ob_y-3,
  819.                                          tree->ob_width+6,tree->ob_height+6);
  820.  
  821.     graf_mouse(M_OFF,0L);
  822.     pxyarray[0]=0;
  823.     pxyarray[1]=0;
  824.     pxyarray[2]=tree->ob_width-1+6;
  825.     pxyarray[3]=tree->ob_height-1+6;
  826.     pxyarray[4]=tree->ob_x-3;
  827.     pxyarray[5]=tree->ob_y-3;
  828.     pxyarray[6]=tree->ob_x+tree->ob_width-1+3;
  829.     pxyarray[7]=tree->ob_y+tree->ob_height-1+3;
  830.     vro_cpyfm(vdihandle,3,pxyarray,&pd[FDBcount],&ps[FDBcount]);
  831.     graf_mouse(M_ON,0L);
  832.  
  833.     if(exit_obj > -1 /*&& exit_obj < 256*/)
  834.         tree[exit_obj].ob_state &= ~SELECTED;
  835. #if GEMDOS
  836.     Mfree(pb[FDBcount].fd_addr);
  837.     Mfree(pd[FDBcount].fd_addr);
  838. #else
  839.     farfree(pb[FDBcount].fd_addr);
  840.     farfree(pd[FDBcount].fd_addr);
  841. #endif
  842.     pd[FDBcount].fd_addr=NULL;
  843.     pb[FDBcount].fd_addr=NULL;
  844.  
  845.     return(exit_obj);
  846. }
  847.  
  848. #if GEMDOS
  849. static void set_menu(int enable)
  850. {
  851.     int id,obj;
  852.     static int width=0;
  853.     extern int gl_apid;
  854.     #define THEACTIVE 2
  855.  
  856.     wind_update(BEG_UPDATE);
  857.     if (enable)
  858.     {
  859. #ifdef GEISS
  860.         winmenu [THEACTIVE].ob_width = width;
  861.         menu_bar(winmenu,TRUE);
  862. #else
  863.         for(obj=ROOT+4; winmenu[obj].ob_type==G_TITLE; obj++)
  864.             menu_ienable(winmenu,obj,TRUE);
  865.         menu_ienable(winmenu,obj+2,TRUE);
  866.         winmenu [THEACTIVE].ob_width = width;
  867. /*
  868.         if(_GemParBlk.global[0]>=0x0400)
  869.         {
  870.             id=menu_bar(winmenu,-1);
  871.             if(id==gl_apid)
  872.                 menu_bar(winmenu,TRUE);
  873.         }
  874.         else
  875. */
  876.             menu_bar(winmenu,TRUE);
  877. #endif
  878.  
  879.     }
  880.     else
  881.         if (winmenu [THEACTIVE].ob_width != 0)
  882.         {
  883. #ifdef GEISS
  884.             width = winmenu [THEACTIVE].ob_width;
  885.             winmenu [THEACTIVE].ob_width = 0;
  886. #else
  887.             for(obj=ROOT+4; winmenu[obj].ob_type==G_TITLE; obj++)
  888.                 menu_ienable(winmenu,obj,FALSE);
  889.             menu_ienable(winmenu,obj+2,FALSE);
  890.             width = winmenu [THEACTIVE].ob_width;
  891.             winmenu [THEACTIVE].ob_width = winmenu [ROOT+3].ob_x +
  892.                                                      winmenu [ROOT+3].ob_width;
  893.             menu_bar(winmenu,TRUE);
  894. #endif
  895.         } /* if, else */
  896.     wind_update(END_UPDATE);
  897. }
  898.  
  899. static void form_size(OBJECT *tree, int h)
  900. {
  901.     register int i;
  902.     
  903.     tree[ROOT].ob_state&=~OUTLINED;
  904.     tree[ROOT].ob_spec.obspec.framesize=0;
  905.     tree[ROOT+1].ob_flags|=HIDETREE;
  906.     tree[ROOT+2].ob_flags|=HIDETREE;
  907. /*
  908.     if(!(tree->ob_flags & 0x0400))/* Wäre Hilfedialog, aber kein Handle */
  909. */
  910.     {
  911.         tree[ROOT].ob_y+=(h/2);
  912.         tree[ROOT].ob_height-=h;
  913.         for(i=ROOT+1; i; i=tree[i].ob_next)
  914.         {
  915.             tree[i].ob_y-=h;
  916.             if(tree[i].ob_next==ROOT)
  917.                 break;
  918.         }
  919.     }
  920. }
  921.  
  922. static void form_resize(OBJECT *tree, int h)
  923. {
  924.     register int i;
  925.  
  926.     tree[ROOT].ob_state|=OUTLINED;
  927.     tree[ROOT].ob_spec.obspec.framesize=2;
  928.     tree[ROOT+1].ob_flags&=~HIDETREE;
  929.     tree[ROOT+2].ob_flags&=~HIDETREE;
  930. /*
  931.     if(!(tree->ob_flags & 0x0400)) /* Wäre Hilfedialog, aber kein Handle */
  932. */
  933.     {
  934.         tree[ROOT].ob_y-=(h/2);
  935.         tree[ROOT].ob_height+=h;
  936.         for(i=ROOT+1; i; i=tree[i].ob_next)
  937.         {
  938.             tree[i].ob_y+=h;
  939.             if(tree[i].ob_next==ROOT)
  940.                 break;
  941.         }
  942.     }
  943. }
  944. #endif
  945.  
  946. int objc_sysvar(int ob_smode, int ob_swhich, 
  947.                      int ob_sival1, int ob_sival2,
  948.                 int *ob_soval1, int *ob_soval2 )
  949. {
  950.     AESPB aespb=
  951.     {
  952.         _GemParBlk.contrl,
  953.         _GemParBlk.global,
  954.         _GemParBlk.intin,
  955.         _GemParBlk.intout,
  956.         _GemParBlk.addrin,
  957.         _GemParBlk.addrout
  958.     };
  959.  
  960.     _GemParBlk.intin [0] = ob_smode;
  961.     _GemParBlk.intin [1] = ob_swhich;
  962.     _GemParBlk.intin [2] = ob_sival1;
  963.     _GemParBlk.intin [3] = ob_sival2;
  964.  
  965.     _GemParBlk.contrl[0]=48;
  966.     _GemParBlk.contrl[1]=4;    
  967.     _GemParBlk.contrl[2]=3;    
  968.     _GemParBlk.contrl[3]=0;    
  969.     _GemParBlk.contrl[4]=0;    
  970.  
  971.     _crystal(&aespb);
  972.  
  973.     *ob_soval1 = _GemParBlk.intout[1];
  974.     *ob_soval2 = _GemParBlk.intout[2];
  975.  
  976.     return(_GemParBlk.intout[0]);
  977. }
  978.  
  979. int mindestens_16_Farben(void)
  980. {
  981.     extern int work_out[];
  982.  
  983.     vq_extnd(vdihandle,1,work_out);
  984.     return(work_out[4]>=4?TRUE:FALSE); /* 4 Farbplanes = 16 Farben*/
  985. }
  986.  
  987. int form_exopen(OBJECT *tree, int modus)
  988. {
  989. #if GEMDOS
  990. /*
  991.     static int msgbuf[8];
  992.     static MEVENT mevent=
  993.     {
  994.         MU_MESAG|MU_TIMER,
  995.         0,0,0,
  996.         0,0,0,0,0,
  997.         0,0,0,0,0,
  998.         msgbuf,
  999.         0L,                    /* bei Makro: 16L, */
  1000.         0,0,0,0,0,0,
  1001.     /* nur der Vollständigkeit halber die Variablen von XGEM */
  1002.         0,0,0,0,0,
  1003.         0,
  1004.         0L,
  1005.         0L,0L
  1006.     };
  1007. */
  1008.     INFOVSCR *infovscr;
  1009.     int mx,my,ret,kstate;
  1010.     int x,y,w,h;
  1011.     int wi_kind=NAME|MOVER;
  1012.     extern int dialbgcolor,actbutcolor; /* 3D-Look */
  1013.     
  1014.     graf_mouse(M_ON, NULL);/* nur bei eventgesteuerter Maus */
  1015.  
  1016.     graf_mkstate(&mx,&my,&ret,&kstate);
  1017.     if(divmenu[DIVZENT].ob_state&SELECTED)         /* immer zentrieren */
  1018.         form_center(tree,&ret,&ret,&ret,&ret);
  1019.  
  1020.     if(divmenu[DIVFREE].ob_state&SELECTED)         /* frei */
  1021.         ;
  1022.  
  1023.     if(divmenu[DIVMAUS].ob_state&SELECTED)         /* zur Maus */
  1024.         pop_excenter(tree,mx,my,&ret,&ret,&ret,&ret);
  1025.  
  1026.     if(!letemfly) /* Let 'em fly übernimmt das Fliegen, weil schneller */
  1027.         letemfly = (LTMFLY *)get_cookie('LTMF');
  1028.     if(letemfly && letemfly->config.bypass)
  1029.         letemfly=NULL;
  1030.  
  1031.     if(kstate & (K_LSHIFT|K_RSHIFT)) /* Bei gedrückter Controltaste... */
  1032.         form_center(tree,&ret,&ret,&ret,&ret);     /* ...zentrieren */
  1033.  
  1034.     if((infovscr=(INFOVSCR *)get_cookie('VSCR'))!=NULL) /* BigScreen 2 */
  1035.     {
  1036.         if(infovscr->cookie=='VSCR')
  1037.         {
  1038.             tree->ob_x=infovscr->x+(infovscr->w-tree->ob_width)/2;
  1039.             tree->ob_y=infovscr->y+(infovscr->h-tree->ob_height)/2+ydesk;
  1040.         }
  1041.     }
  1042.     actbutcolor=WHITE;
  1043.     dialbgcolor=WHITE;
  1044.     if(_GemParBlk.global[0]>=0x0340 /*&& mindestens_16_Farben()*/)
  1045.     {  /* erst prüfen, ob implementiert */
  1046.         if(objc_sysvar(0,4/*ACTBUTCOL*/,0,0,&actbutcolor,&ret)>0)
  1047.             objc_sysvar(0,5/*BACKGRCOL*/,0,0,&dialbgcolor,&ret);
  1048.         else
  1049.             actbutcolor=WHITE;
  1050.     }
  1051.     if(get_cookie('MagX'))
  1052.         wi_kind|=BACKDROP;
  1053.     if(windials && !(tree->ob_flags & FLAGS15) &&
  1054.         (dial_handle=wind_create(wi_kind,xdesk,ydesk,wdesk,hdesk))>0)
  1055.     {
  1056.         set_menu(FALSE);
  1057.         wind_set(dial_handle,WF_NAME,(char *)((TEDINFO *)tree[ROOT+2].ob_spec.userblk->ub_parm)->te_ptext);
  1058.         form_size(tree, 2*boxh);
  1059.         wind_calc(WC_BORDER,NAME|MOVER,tree->ob_x,tree->ob_y,tree->ob_width,tree->ob_height,&x,&y,&w,&h);
  1060.         if(y<ydesk) /* MOVER nicht in Menüzeile */
  1061.         {
  1062.             tree->ob_y+=(ydesk-y);
  1063.             y=ydesk;
  1064.         }
  1065.         if(modus)
  1066.             form_dial(FMD_GROW,0,0,0,0,tree->ob_x,tree->ob_y,tree->ob_width,tree->ob_height);
  1067.         wind_open(dial_handle,x,y,w,h);
  1068. /*
  1069.         undotree=form_copy(tree,0);
  1070. */
  1071.         return(dial_handle);
  1072.     }
  1073.     else
  1074.     {
  1075.     #if MiNT
  1076.         wind_update(BEG_UPDATE);
  1077.         wind_update(BEG_MCTRL);
  1078.     #endif
  1079.         if(letemfly)
  1080.             form_open(tree, modus);
  1081.         else
  1082.         {
  1083.             FDBcount++;
  1084.             if(!_form_exopen(tree, modus))
  1085.             {
  1086.                 tree[ROOT+1].ob_flags|=HIDETREE;
  1087.                 form_open(tree, modus);
  1088.             }
  1089.         }
  1090. /*
  1091.         undotree=form_copy(tree,0);
  1092. */
  1093.         return(FDBcount);
  1094.     }
  1095. #else
  1096.  
  1097.     graf_mouse(M_ON, NULL);/* nur bei eventgesteuerter Maus */
  1098.  
  1099. #if MiNT
  1100.     wind_update(BEG_UPDATE);
  1101.     wind_update(BEG_MCTRL);
  1102. #endif
  1103.     if(tree[ROOT+1].ob_flags&TOUCHEXIT)
  1104.     {
  1105.         tree[ROOT+1].ob_flags&=~TOUCHEXIT;
  1106.         tree[ROOT+1].ob_flags|=HIDETREE;
  1107.     }
  1108.     form_open(tree, modus);
  1109. /*
  1110.     undotree=form_copy(tree,0);
  1111. */
  1112.     return(FALSE);
  1113. #endif
  1114. }
  1115.  
  1116. int form_exclose(OBJECT *tree, int exit_obj, int modus)
  1117. {
  1118. /*
  1119.     if(undotree)
  1120.         free(undotree);
  1121. */
  1122. #if GEMDOS
  1123.     if(dial_handle>0 && !(tree->ob_flags & FLAGS15))
  1124.     {
  1125.         wind_close(dial_handle);
  1126.         wind_delete(dial_handle);
  1127.         if(modus)
  1128.             form_dial(FMD_SHRINK,0,0,0,0,tree->ob_x,tree->ob_y,tree->ob_width,tree->ob_height);
  1129.         form_resize(tree, 2*boxh);
  1130.         if(exit_obj > -1)
  1131.             tree[exit_obj].ob_state &= ~SELECTED;
  1132.         set_menu(TRUE);
  1133.         dial_handle=-1;
  1134.     }
  1135.     else
  1136.     {
  1137.         if(letemfly)
  1138.             form_close(tree, exit_obj, modus);
  1139.         else
  1140.         {
  1141.             if(FDBcount<MAX_DEPTH && pd[FDBcount].fd_addr)
  1142.                 _form_exclose(tree, exit_obj, modus);
  1143.             else
  1144.             {
  1145.                 form_close(tree, exit_obj, modus);
  1146.                 tree[ROOT+1].ob_flags&=~HIDETREE;
  1147.             }
  1148.             FDBcount--;
  1149.         }
  1150. #if MiNT
  1151.         wind_update(END_MCTRL);
  1152.         wind_update(END_UPDATE);
  1153. #endif
  1154.     }
  1155. #else
  1156.     form_close(tree, exit_obj, modus);
  1157. #if MiNT
  1158.     wind_update(END_MCTRL);
  1159.     wind_update(END_UPDATE);
  1160. #endif
  1161. #endif
  1162.     return(exit_obj);
  1163. }
  1164. #if GEMDOS
  1165. static void _form_trans(OBJECT *tree)
  1166. {
  1167.     int pxyarray[8];
  1168.     extern int xdesk,ydesk,wdesk,hdesk;
  1169.  
  1170.     graf_mouse(M_OFF,0L);
  1171.     pxyarray[0]=tree->ob_x-3;
  1172.     pxyarray[1]=tree->ob_y-3;
  1173.     pxyarray[2]=tree->ob_x+tree->ob_width-1+3;
  1174.     pxyarray[3]=tree->ob_y+tree->ob_height-1+3;
  1175.     pxyarray[4]=0;
  1176.     pxyarray[5]=0;
  1177.     pxyarray[6]=tree->ob_width-1+6;
  1178.     pxyarray[7]=tree->ob_height-1+6;
  1179.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&ps[FDBcount],&pb[FDBcount]);
  1180.  
  1181.     pxyarray[0]=0;
  1182.     pxyarray[1]=0;
  1183.     pxyarray[2]=tree->ob_width-1+6;
  1184.     pxyarray[3]=tree->ob_height-1+6;
  1185.     pxyarray[4]=tree->ob_x-3;
  1186.     pxyarray[5]=tree->ob_y-3;
  1187.     pxyarray[6]=tree->ob_x+tree->ob_width-1+3;
  1188.     pxyarray[7]=tree->ob_y+tree->ob_height-1+3;
  1189.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pd[FDBcount],&ps[FDBcount]);
  1190.     graf_mouse(M_ON,0L);
  1191.  
  1192.     graf_mouse(FLAT_HAND,NULL);
  1193.     graf_dragbox(tree->ob_width,tree->ob_height,tree->ob_x,tree->ob_y,
  1194.                       xdesk+3,ydesk+3,wdesk-6,hdesk-6,&tree->ob_x,&tree->ob_y);
  1195.     graf_mouse(ARROW,NULL);
  1196.  
  1197.     graf_mouse(M_OFF,0L);
  1198.     pxyarray[0]=tree->ob_x-3;
  1199.     pxyarray[1]=tree->ob_y-3;
  1200.     pxyarray[2]=tree->ob_x+tree->ob_width-1+3;
  1201.     pxyarray[3]=tree->ob_y+tree->ob_height-1+3;
  1202.     pxyarray[4]=0;
  1203.     pxyarray[5]=0;
  1204.     pxyarray[6]=tree->ob_width-1+6;
  1205.     pxyarray[7]=tree->ob_height-1+6;
  1206.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&ps[FDBcount],&pd[FDBcount]);
  1207.  
  1208.     pxyarray[0]=0;
  1209.     pxyarray[1]=0;
  1210.     pxyarray[2]=tree->ob_width-1+6;
  1211.     pxyarray[3]=tree->ob_height-1+6;
  1212.     pxyarray[4]=tree->ob_x-3;
  1213.     pxyarray[5]=tree->ob_y-3;
  1214.     pxyarray[6]=tree->ob_x+tree->ob_width-1+3;
  1215.     pxyarray[7]=tree->ob_y+tree->ob_height-1+3;
  1216.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pb[FDBcount],&ps[FDBcount]);
  1217.     graf_mouse(M_ON,0L);
  1218. }
  1219.  
  1220. static void _form_frame(OBJECT *tree)
  1221. {
  1222.     extern int xdesk,ydesk,wdesk,hdesk;
  1223.     int x,y,pxyarray[8];
  1224.  
  1225.     graf_mouse(FLAT_HAND,NULL);
  1226.     graf_dragbox(tree->ob_width,tree->ob_height,tree->ob_x,tree->ob_y,
  1227.                       xdesk+3,ydesk+3,wdesk-6,hdesk-6,&x,&y);
  1228.     graf_mouse(ARROW,NULL);
  1229.  
  1230.     graf_mouse(M_OFF,0L);
  1231.  
  1232.     pxyarray[0]=tree->ob_x-3;
  1233.     pxyarray[1]=tree->ob_y-3;
  1234.     pxyarray[2]=tree->ob_x+tree->ob_width-1+3;
  1235.     pxyarray[3]=tree->ob_y+tree->ob_height-1+3;
  1236.     pxyarray[4]=0;
  1237.     pxyarray[5]=0;
  1238.     pxyarray[6]=tree->ob_width-1+6;
  1239.     pxyarray[7]=tree->ob_height-1+6;
  1240.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&ps[FDBcount],&pb[FDBcount]);
  1241.  
  1242.     pxyarray[0]=0;
  1243.     pxyarray[1]=0;
  1244.     pxyarray[2]=tree->ob_width-1+6;
  1245.     pxyarray[3]=tree->ob_height-1+6;
  1246.     pxyarray[4]=tree->ob_x-3;
  1247.     pxyarray[5]=tree->ob_y-3;
  1248.     pxyarray[6]=tree->ob_x+tree->ob_width-1+3;
  1249.     pxyarray[7]=tree->ob_y+tree->ob_height-1+3;
  1250.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pd[FDBcount],&ps[FDBcount]);
  1251.  
  1252.     tree->ob_x=x;
  1253.     tree->ob_y=y;
  1254.  
  1255.     pxyarray[0]=tree->ob_x-3;
  1256.     pxyarray[1]=tree->ob_y-3;
  1257.     pxyarray[2]=tree->ob_x+tree->ob_width-1+3;
  1258.     pxyarray[3]=tree->ob_y+tree->ob_height-1+3;
  1259.     pxyarray[4]=0;
  1260.     pxyarray[5]=0;
  1261.     pxyarray[6]=tree->ob_width-1+6;
  1262.     pxyarray[7]=tree->ob_height-1+6;
  1263.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&ps[FDBcount],&pd[FDBcount]);
  1264.  
  1265.     pxyarray[0]=0;
  1266.     pxyarray[1]=0;
  1267.     pxyarray[2]=tree->ob_width-1+6;
  1268.     pxyarray[3]=tree->ob_height-1+6;
  1269.     pxyarray[4]=tree->ob_x-3;
  1270.     pxyarray[5]=tree->ob_y-3;
  1271.     pxyarray[6]=tree->ob_x+tree->ob_width-1+3;
  1272.     pxyarray[7]=tree->ob_y+tree->ob_height-1+3;
  1273.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pb[FDBcount],&ps[FDBcount]);
  1274.     graf_mouse(M_ON,0L);
  1275. }
  1276.  
  1277. static int _form_move(OBJECT *tree, int xdiff, int ydiff)
  1278. {
  1279.     int pxyarray[8];
  1280.  
  1281.     graf_mouse(M_OFF,0L);
  1282.     pxyarray[0]=tree->ob_x+xdiff-3; /* neuen Bereich sichern */
  1283.     pxyarray[1]=tree->ob_y+ydiff-3;
  1284.     pxyarray[2]=tree->ob_x+xdiff+tree->ob_width-1+3;
  1285.     pxyarray[3]=tree->ob_y+ydiff+tree->ob_height-1+3;
  1286.     pxyarray[4]=0;
  1287.     pxyarray[5]=0;
  1288.     pxyarray[6]=tree->ob_width-1+6;
  1289.     pxyarray[7]=tree->ob_height-1+6;
  1290.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&ps[FDBcount],&pb[FDBcount]);
  1291.  
  1292.     pxyarray[0]=tree->ob_x-3;        /* Box verschieben */
  1293.     pxyarray[1]=tree->ob_y-3;
  1294.     pxyarray[2]=tree->ob_x+tree->ob_width-1+3;
  1295.     pxyarray[3]=tree->ob_y+tree->ob_height-1+3;
  1296.     pxyarray[4]=tree->ob_x+xdiff-3;
  1297.     pxyarray[5]=tree->ob_y+ydiff-3;
  1298.     pxyarray[6]=tree->ob_x+xdiff+tree->ob_width-1+3;
  1299.     pxyarray[7]=tree->ob_y+ydiff+tree->ob_height-1+3;
  1300.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&ps[FDBcount],&ps[FDBcount]);
  1301.  
  1302.     pxyarray[0]=0;                      /* alten Hintergrund restaurieren */
  1303.     pxyarray[1]=0;
  1304.     pxyarray[2]=tree->ob_width-1+6;
  1305.     pxyarray[3]=tree->ob_height-1+6;
  1306.     pxyarray[4]=tree->ob_x-3;
  1307.     pxyarray[5]=tree->ob_y-3;
  1308.     pxyarray[6]=tree->ob_x+tree->ob_width-1+3;
  1309.     pxyarray[7]=tree->ob_y+tree->ob_height-1+3;
  1310.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pd[FDBcount],&ps[FDBcount]);
  1311.  
  1312.     pxyarray[0]=0;                 /* Boxbuffer nach Destbuffer umkopieren */
  1313.     pxyarray[1]=0;
  1314.     pxyarray[2]=tree->ob_width-1+6;
  1315.     pxyarray[3]=tree->ob_height-1+6;
  1316.     pxyarray[4]=0;
  1317.     pxyarray[5]=0;
  1318.     pxyarray[6]=tree->ob_width-1+6;
  1319.     pxyarray[7]=tree->ob_height-1+6;
  1320.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pb[FDBcount],&pd[FDBcount]);
  1321.     graf_mouse(M_ON,0L);
  1322.  
  1323.     tree->ob_x+=xdiff;
  1324.     tree->ob_y+=ydiff;
  1325.     return(TRUE);
  1326. }
  1327.  
  1328. static int _form_fly(register OBJECT *tree, register int xdiff, register int ydiff)
  1329. {
  1330.     register int pxyarray[8];
  1331.  
  1332.     if(abs(xdiff)>tree->ob_width+6-1 || abs(ydiff)>tree->ob_height+6-1)
  1333.         return(_form_move(tree,xdiff,ydiff));
  1334.                                               /* verschieben wenn keine Überlappung */
  1335.  
  1336.     graf_mouse(M_OFF,0L);
  1337.     pxyarray[0]=tree->ob_x+xdiff-3; /* neuen zu überlappenden Bereich sichern */
  1338.     pxyarray[1]=tree->ob_y+ydiff-3;
  1339.     pxyarray[2]=tree->ob_x+xdiff+tree->ob_width+3-1;
  1340.     pxyarray[3]=tree->ob_y+ydiff+tree->ob_height+3-1;
  1341.     pxyarray[4]=0;
  1342.     pxyarray[5]=0;
  1343.     pxyarray[6]=tree->ob_width+6-1;
  1344.     pxyarray[7]=tree->ob_height+6-1;
  1345.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&ps[FDBcount],&pb[FDBcount]);
  1346.  
  1347.     pxyarray[0]=tree->ob_x-3;         /* Box verschieben */
  1348.     pxyarray[1]=tree->ob_y-3;
  1349.     pxyarray[2]=tree->ob_x+tree->ob_width+3-1;
  1350.     pxyarray[3]=tree->ob_y+tree->ob_height+3-1;
  1351.     pxyarray[4]=tree->ob_x+xdiff-3;
  1352.     pxyarray[5]=tree->ob_y+ydiff-3;
  1353.     pxyarray[6]=tree->ob_x+xdiff+tree->ob_width+3-1;
  1354.     pxyarray[7]=tree->ob_y+ydiff+tree->ob_height+3-1;
  1355.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&ps[FDBcount],&ps[FDBcount]);
  1356.  
  1357.     if(xdiff<0)                    /* frei werdende Rechtecke wieder restaurieren */
  1358.     {
  1359.         pxyarray[0]=tree->ob_width+6+xdiff;
  1360.         pxyarray[1]=0;
  1361.         pxyarray[2]=tree->ob_width+6-1;
  1362.         pxyarray[3]=tree->ob_height+6-1;
  1363.         pxyarray[4]=tree->ob_x+tree->ob_width+3+xdiff;
  1364.         pxyarray[5]=tree->ob_y-3;
  1365.         pxyarray[6]=tree->ob_x+tree->ob_width+3-1;
  1366.         pxyarray[7]=tree->ob_y+tree->ob_height+3-1;
  1367.         vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pd[FDBcount],&ps[FDBcount]);
  1368.     }
  1369.     if(xdiff>0)
  1370.     {
  1371.  
  1372.         pxyarray[0]=0;
  1373.         pxyarray[1]=0;
  1374.         pxyarray[2]=xdiff-1;
  1375.         pxyarray[3]=tree->ob_height+6-1;
  1376.         pxyarray[4]=tree->ob_x-3;
  1377.         pxyarray[5]=tree->ob_y-3;
  1378.         pxyarray[6]=tree->ob_x-3+xdiff-1;
  1379.         pxyarray[7]=tree->ob_y+tree->ob_height+3-1;
  1380.         vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pd[FDBcount],&ps[FDBcount]);
  1381.  
  1382.     }
  1383.     if(ydiff<0)
  1384.     {
  1385.         pxyarray[0]=0;
  1386.         pxyarray[1]=tree->ob_height+6+ydiff;
  1387.         pxyarray[2]=tree->ob_width+6-1;
  1388.         pxyarray[3]=tree->ob_height+6-1;
  1389.         pxyarray[4]=tree->ob_x-3;
  1390.         pxyarray[5]=tree->ob_y+tree->ob_height+3+ydiff;
  1391.         pxyarray[6]=tree->ob_x+tree->ob_width+3-1;
  1392.         pxyarray[7]=tree->ob_y+tree->ob_height+3-1;
  1393.         vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pd[FDBcount],&ps[FDBcount]);
  1394.     }
  1395.     if(ydiff>0)
  1396.     {
  1397.         pxyarray[0]=0;
  1398.         pxyarray[1]=0;
  1399.         pxyarray[2]=tree->ob_width+6-1;
  1400.         pxyarray[3]=ydiff-1;
  1401.         pxyarray[4]=tree->ob_x-3;
  1402.         pxyarray[5]=tree->ob_y-3;
  1403.         pxyarray[6]=tree->ob_x+tree->ob_width+3-1;
  1404.         pxyarray[7]=tree->ob_y-3+ydiff-1;
  1405.         vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pd[FDBcount],&ps[FDBcount]);
  1406.     }
  1407.  
  1408.     graf_mouse(M_ON,0L);
  1409.  
  1410.     pxyarray[0]=(xdiff>0?xdiff:0); /* Rest von Destbuffer nach Boxbuffer umkopieren */
  1411.     pxyarray[1]=(ydiff>0?ydiff:0);
  1412.     pxyarray[2]=tree->ob_width+6-1-(xdiff>0?0:-xdiff);
  1413.     pxyarray[3]=tree->ob_height+6-1-(ydiff>0?0:-ydiff);
  1414.     pxyarray[4]=(xdiff>0?0:-xdiff);
  1415.     pxyarray[5]=(ydiff>0?0:-ydiff);
  1416.     pxyarray[6]=tree->ob_width+6-1-(xdiff>0?xdiff:0);
  1417.     pxyarray[7]=tree->ob_height+6-1-(ydiff>0?ydiff:0);
  1418.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pd[FDBcount],&pb[FDBcount]);
  1419.  
  1420.     pxyarray[0]=0; /* Boxbuffer nach Destbuffer umkopieren */
  1421.     pxyarray[1]=0;
  1422.     pxyarray[2]=tree->ob_width+6-1;
  1423.     pxyarray[3]=tree->ob_height+6-1;
  1424.     pxyarray[4]=0;
  1425.     pxyarray[5]=0;
  1426.     pxyarray[6]=tree->ob_width+6-1;
  1427.     pxyarray[7]=tree->ob_height+6-1;
  1428.     vro_cpyfm(vdihandle,S_ONLY,pxyarray,&pb[FDBcount],&pd[FDBcount]);
  1429. /*
  1430.     memmove(pd[FDBcount].fd_addr,pb[FDBcount].fd_addr,
  1431.         (long)pd[FDBcount].fd_wdwidth*2L*(long)pd[FDBcount].fd_h*(long)pd[FDBcount].fd_nplanes);
  1432. */
  1433.     tree->ob_x+=xdiff;
  1434.     tree->ob_y+=ydiff;
  1435.     return(TRUE);
  1436. }
  1437. #endif
  1438. int form_exdo(OBJECT *tree, int start)
  1439. {
  1440.     int event,mx,my,oldx,oldy,mstate,ret,kstate,exit_obj;
  1441.     int lw,rw,uh,lh,pxy[4];
  1442.     extern int xdesk,ydesk,wdesk,hdesk,work_out[];
  1443. /*
  1444.     static MEVENT mevent=
  1445.     {
  1446.         MU_BUTTON|MU_M1,
  1447.         1,1,0,
  1448.         1,0,0,1,1,
  1449.         0,0,0,0,0,
  1450.         NULL,
  1451.         0L,
  1452.         0,0,0,0,0,0,
  1453.     /* nur der Vollständigkeit halber die Variablen von XGEM */
  1454.         0,0,0,0,0,
  1455.         0,
  1456.         0L,
  1457.         0L,0L
  1458.     };
  1459. */
  1460. #if GEMDOS
  1461.     vq_extnd(vdihandle,1,work_out);
  1462.     pxy[0]=xdesk;
  1463.     pxy[1]=ydesk;
  1464.     pxy[2]=xdesk+wdesk-1;
  1465.     pxy[3]=ydesk+hdesk-1;
  1466.     vs_clip(vdihandle,FALSE,pxy);
  1467. #endif
  1468.     do
  1469.     {
  1470.         exit_obj=_form_exdo(tree, start);
  1471. #if GEMDOS
  1472.         if((exit_obj&0x7FFF)==(ROOT+1))
  1473.         {
  1474.             if(letemfly && !letemfly->config.bypass) /* mit Let 'em fly, weil schneller ist. */
  1475.             {
  1476.                 letemfly->di_fly(tree);
  1477.             }
  1478.             else
  1479.             {
  1480.                 graf_mkstate(&mx,&my,&mstate,&kstate);
  1481.                 oldx = mx;
  1482.                 oldy = my;
  1483.                 if(mstate&2)
  1484.                     kstate=K_LSHIFT; /* auch wenn beide Maustasten gedrückt */
  1485.                 if(kstate)
  1486.                 {
  1487.                     _form_trans(tree);
  1488.                 }
  1489.                 else
  1490.                 {
  1491.                     if(work_out[6]>2000)
  1492.                     {
  1493.                         lw=mx-tree->ob_x+3; /* wo steht die Maus in der Box? */
  1494.                         rw=tree->ob_x+tree->ob_width+3-mx;
  1495.                         uh=my-tree->ob_y+3;
  1496.                         lh=tree->ob_y+tree->ob_height+3-my;
  1497. /*
  1498.                           mevent.e_m1.g_x=mx;
  1499.                           mevent.e_m1.g_y=my;
  1500. */
  1501.                         graf_mouse(FLAT_HAND,NULL);
  1502.                         do
  1503.                         {
  1504.                             graf_mkstate(&mx, &my, &mstate, &ret);
  1505.                             if(mx != oldx || my != oldy)
  1506.                             {
  1507.                                 if(mx-lw<xdesk)
  1508.                                     mx=xdesk+lw;
  1509.                                 if(my-uh<ydesk)
  1510.                                     my=ydesk+uh;
  1511.                                 if(mx+rw>xdesk+wdesk)
  1512.                                     mx=xdesk+wdesk-rw;
  1513.                                 if(my+lh>ydesk+hdesk)
  1514.                                     my=ydesk+hdesk-lh;
  1515.                                 /* Flieg los, Huhn */
  1516.                                 _form_fly(tree,mx-oldx,my-oldy);
  1517.                                 oldx = mx;
  1518.                                 oldy = my;
  1519.                             }
  1520.                         }
  1521.                         while(mstate);
  1522. /* geht nicht auf dem Falcon
  1523.                         do
  1524.                         {
  1525.                             event=evnt_event(&mevent);
  1526.                             if(event & MU_M1)
  1527.                             {
  1528.                                 mx=mevent.e_mx;
  1529.                                 my=mevent.e_my;
  1530.     
  1531.                                 if(mx-lw<xdesk)
  1532.                                     mx=xdesk+lw;
  1533.                                 if(my-uh<ydesk)
  1534.                                     my=ydesk+uh;
  1535.                                 if(mx+rw>xdesk+wdesk)
  1536.                                     mx=xdesk+wdesk-rw;
  1537.                                 if(my+lh>ydesk+hdesk)
  1538.                                     my=ydesk+hdesk-lh;
  1539.     
  1540.                                 /* Flieg los, Huhn */
  1541.                                 _form_fly(tree,mx-mevent.e_m1.g_x,my-mevent.e_m1.g_y);
  1542.     
  1543.                                   mevent.e_m1.g_x=mx;
  1544.                                  mevent.e_m1.g_y=my;
  1545.                              }
  1546.                         }
  1547.                         while(mevent.e_mb & 1); /* linke Maustaste gedrückt */
  1548. */
  1549.                         graf_mouse(ARROW,NULL);
  1550.                     }
  1551.                     else
  1552.                         _form_frame(tree);
  1553.                 }
  1554.             }
  1555.         }
  1556. #endif
  1557.     }
  1558.     while((exit_obj&0x7FFF)==(ROOT+1));
  1559.     return(exit_obj);
  1560. }
  1561.  
  1562. int form_hndl(OBJECT *tree,int start, int modus)
  1563. {
  1564.     int exit_obj;
  1565.  
  1566.     form_open(tree,modus);
  1567.     exit_obj=form_do(tree,start);
  1568.     form_close(tree,exit_obj,modus);
  1569.     return(exit_obj);
  1570. }
  1571.  
  1572. int form_exhndl(OBJECT *tree, int start, int modus)
  1573. {
  1574.     int exit_obj;
  1575.     form_exopen(tree,modus);
  1576.     exit_obj=form_exdo(tree, start);
  1577.     form_exclose(tree, exit_obj, modus);
  1578.     return(exit_obj);
  1579. }
  1580.  
  1581. void pop_excenter(OBJECT *tree, int mx, int my, int *x, int *y, int *w, int *h)
  1582. {
  1583.     extern int xdesk,ydesk,wdesk,hdesk;
  1584.  
  1585.     tree->ob_x = mx-tree->ob_width/2;
  1586.     if(tree->ob_x<xdesk+3)
  1587.         tree->ob_x=xdesk+3;
  1588.     tree->ob_y = my-tree->ob_height/2;
  1589.     if(tree->ob_y<ydesk+3)
  1590.         tree->ob_y=ydesk+3;
  1591.     if(tree->ob_x+tree->ob_width > wdesk-3)
  1592.         tree->ob_x=wdesk-tree->ob_width-3;
  1593.     if(tree->ob_y+tree->ob_height > ydesk+hdesk-3)
  1594.         tree->ob_y=ydesk+hdesk-tree->ob_height-3;
  1595.     *x=tree->ob_x;
  1596.     *y=tree->ob_y;
  1597.     *w=tree->ob_width;
  1598.     *h=tree->ob_height;
  1599. }
  1600.  
  1601. int pop_do(OBJECT *tree, int close_at_once)
  1602. {
  1603.     int mx,my,mouse_click,oum,noum,ret,x,y,w,h,event,leave,mobutton,bmsk=1;
  1604. /*    unsigned int key,kstate; */
  1605.     GRECT r;
  1606.  
  1607.     x=tree->ob_x;
  1608.     y=tree->ob_y;
  1609.     w=tree->ob_width;
  1610.     h=tree->ob_height;
  1611.  
  1612.     graf_mkstate (&mx, &my, &mobutton, &ret);
  1613.  
  1614.     noum=oum=objc_find(tree,0,8,mx,my);
  1615.     if(oum != -1)
  1616.         if((tree[oum].ob_flags & SELECTABLE) && !(tree[oum].ob_state & DISABLED))
  1617.             objc_change(tree,oum,0,x,y,w,h,tree[oum].ob_state|SELECTED,1);
  1618.  
  1619.     do
  1620.     {
  1621.         if(noum != -1)                              /* In Menüeintrag */
  1622.         {
  1623.             objc_offset(tree,noum,&r.g_x,&r.g_y);
  1624.             r.g_w=tree[noum].ob_width;
  1625.             r.g_h=tree[noum].ob_height;
  1626.             leave = TRUE;
  1627.         } /* if */
  1628.         else                                          /* Außerhalb Pop-Up-Menü */
  1629.         {
  1630.             objc_offset(tree,ROOT,&r.g_x,&r.g_y);
  1631.             r.g_w=w;
  1632.             r.g_h=h;
  1633.             leave = FALSE;
  1634.         } /* else */
  1635.  
  1636.         event=evnt_multi (/*MU_KEYBD|*/MU_BUTTON|MU_M1,
  1637.                                 1, bmsk, ~ mobutton & bmsk,
  1638.                                 leave, r.g_x, r.g_y, r.g_w, r.g_h,
  1639.                                 0, 0, 0, 0, 0,
  1640.                                 NULL, 0, 0,
  1641.                                 &mx, &my, &ret, &ret, &ret, &ret);
  1642. /*
  1643.         if(event&MU_BUTTON)
  1644. */
  1645.             noum=objc_find(tree,0,MAX_DEPTH,mx,my);
  1646. /*
  1647.         if(event&MU_KEYBD)
  1648.         {
  1649.             MapKey(&kstate,&key);
  1650.             switch(key)
  1651.             {
  1652.                 case 0x8048:/*up*/
  1653.                     if(oum>ROOT+1)
  1654.                         noum--;
  1655.                     break;
  1656.                 case 0x8050:/*dn*/
  1657.                     if(!(tree[oum].ob_flags & LASTOB))
  1658.                         noum++;
  1659.                     break;
  1660.                 case 0x8061:/*Undo*/
  1661.                     noum=-1; /*kein break!*/
  1662.                 case 0x400D:/*Enter*/
  1663.                 case 0x000D:/*Return*/
  1664.                     event|=MU_BUTTON;
  1665.                     break;
  1666.             }
  1667.         }    
  1668. */
  1669.         if(oum>0)
  1670.             objc_change(tree, oum,0,x,y,w,h,tree[ oum].ob_state&~SELECTED,1);
  1671.         if(noum>0)
  1672.             objc_change(tree,noum,0,x,y,w,h,tree[noum].ob_state| SELECTED,1);
  1673.         oum=noum;
  1674.     }
  1675.     while(!(event & MU_BUTTON));
  1676.  
  1677.     if (~ mobutton & bmsk) evnt_button (1, bmsk, 0x0000, &ret, &ret, &ret, &ret); /* Warte auf Mausknopf */
  1678.  
  1679.     if(oum>0)
  1680.         tree[oum].ob_state&=~SELECTED;
  1681.     return(oum);
  1682. }
  1683.  
  1684. int pop_exhndl(OBJECT *tree,int mx,int my,int modus)
  1685. {
  1686.     int exit_obj,ret;
  1687.  
  1688.     FDBcount++;
  1689.     wind_update(BEG_MCTRL);
  1690.     pop_excenter(tree,mx,my,&ret,&ret,&ret,&ret);
  1691.     _form_exopen(tree,0);
  1692.     exit_obj=pop_do(tree,modus);
  1693.     _form_exclose(tree,-1,0);
  1694.     evnt_button(1,1,0,&ret,&ret,&ret,&ret);
  1695.     wind_update(END_MCTRL);
  1696.     FDBcount--;
  1697.     return(exit_obj);
  1698. }
  1699.  
  1700. void form_write(OBJECT *tree, int item, char *string, int modus)
  1701. {
  1702.     int len;
  1703.     if(tree[item].ob_type==G_USERDEF)
  1704.     {
  1705. /*
  1706.         len=(int)((TEDINFO *)tree[item].ob_spec.userblk->ub_parm)->te_txtlen;
  1707.         strncpy((char *)((TEDINFO *)tree[item].ob_spec.userblk->ub_parm)->te_ptext,
  1708.             string,len);
  1709.         *(char *)((TEDINFO *)tree[item].ob_spec.userblk->ub_parm)->te_ptext[len]=0;
  1710. */
  1711.         strcpy((char *)((TEDINFO *)tree[item].ob_spec.userblk->ub_parm)->te_ptext,string);
  1712.     }
  1713.     else
  1714.     {
  1715. /*
  1716.        len=tree[item].ob_spec.tedinfo->te_txtlen;
  1717.         strncpy(tree[item].ob_spec.tedinfo->te_ptext,
  1718.             string,len);
  1719.         tree[item].ob_spec.tedinfo->te_ptext[len]=0;
  1720. */
  1721.         strcpy(tree[item].ob_spec.tedinfo->te_ptext,string);
  1722.     }
  1723.     if(modus)
  1724.         objc_update(tree,item,0);
  1725. }
  1726.  
  1727. char *form_read(OBJECT *tree,int item, char *string)
  1728. {
  1729.     if(tree[item].ob_type==G_USERDEF)
  1730.         return(strcpy(string,(char *)((TEDINFO *)tree[item].ob_spec.userblk->ub_parm)->te_ptext));
  1731.     else
  1732.         return(strcpy(string,tree[item].ob_spec.tedinfo->te_ptext));
  1733. }
  1734.